package com.central.common.utils;

import com.central.common.constant.PermissionConstants;
import com.central.common.model.SysRole;

import java.util.List;

/**
 * @author Tindy
 * @date 2021/6/23
 * @describe
 */
public class UserRoleUtil {
    /**
     * 是否系统管理员
     */
    public static boolean checkSysAdmin(List<SysRole> roles) {
        return roles.stream().filter(r -> PermissionConstants.SYS_ADMIN.equals(r.getCode())).count()>0;
    }
    /**
     * 是否全局数据管理员
     */
    public static boolean checkGloDataAdmin(List<SysRole> roles) {
        return roles.stream().filter(r ->"glo_data_admin".equals(r.getCode())).count()>0;
    }

    public static boolean checkProDataAdmin(List<SysRole> proRoles) {
        return proRoles.stream().filter(r ->"pro_data_admin".equals(r.getCode())).count()>0;
    }
    public static boolean checkProAdmin(List<SysRole> proRoles) {
        return proRoles.stream().filter(r ->"pro_admin".equals(r.getCode())).count()>0;
    }
}
